package com.fengwensen.reflection;

public class Test03 {

    public static void main(String[] args) throws ClassNotFoundException {

        Person person = new Student();

        //方式1
        Class c1 = person.getClass();
        System.out.println(c1.hashCode());

        //方式2
        Class c2 = Class.forName("com.fengwensen.reflection.Student");
        System.out.println(c2.hashCode());

        //  方式三
        Class c3 = Student.class;
        System.out.println(c3.hashCode());

        //方式4 基本内置类型的包装类都有一个Type属性

        Class c4 = Integer.TYPE;

        System.out.println(c4.hashCode());

        //获取父类类型
        Class c5 = c1.getSuperclass();
        System.out.println(c5);

        Person p1 = new Teacher();

    }


}


class  Person{
    public String name;

}

class Student extends Person{
    public Student() {
        this.name="学生";
    }
}


class Teacher extends Person{
    public Teacher() {
        this.name="学生";
    }
}
